<?php
namespace Home\Model;
use Think\Model;

/**
 * Description of EmployeeModel
 *
 * @author Dark
 */
class EmployeeModel extends Model {
    /*
     * 添加一个员工信息
     */
    public function createEmployee($data) {
        if(!empty($data)) {
            $this->create();
            return $this->add($data);
        } else {
            Log::write('EmployeeModel->createEmployee($data)传入数据$data为空值！');
            return FALSE;
        }
    }
    
    /*
     * 修改一名员工信息
     */
    public function updateByEmployeeID($id, $data) {
        if(!empty($id)) {
            if(!empty($data)) {
                return $this->where('id='.$id)->data($data)->save();
            } else {
                Log::write('EmployeeModel->updateByEmployeeID($id, $data)传入数据$data为空值！');
                return FALSE;
            }
        } else {
            Log::write('EmployeeModel->updateByEmployeeID($id, $data)传入数据$id为空值！');
            return FALSE;
        }
    }
    
    /*
     * 删除一名员工信息
     */
    public function deleteEmployeeByID($id) {
        if(!empty($id)) {
            return $this->where('employeeID='.$id)->delete();
        } else {
            Log::write('EmployeeModel->deleteEmployeeByID($id)传入数据$id为空值！');
            return FALSE;
        }
    }
    
    /*
     * 查询所有员工
     */
    public function queryAllEmployee() {
        return $results = $this->select();
    }
    
    /*
     * 查询某员工信息
     */
    public function queryByEmployeeID($id) {
        if(!empty($id)) {
            return $this->where('id='.$id)->select();
        } else {
            Log::write('EmployeeModel->queryByEmployeeID($id)传入数据$id为空值！');
            return FALSE;
        }
    }
    
    /*
     * 查询某部门的员工信息
     */
    public function queryBranchEmployeeByBranchID($branchID) {
         if(!empty($branchID)) {
             return $this->where('branch_ID='.$branchID)->select();
         } else {
            Log::write('EmployeeModel->queryBranchEmployeeByBranchID($branchID)传入数据$branchID为空值！');
            return FALSE;
         }
    }
}
